package string;

/**
 * @author LIBOFEI
 * @ClassName BrTest
 * @description
 * @date 2020/10/19 17:52
 * @Version 1.0
 **/
public class BrTest  {

    public static void main(String[] args) {

//        String str = "111111111<br/>2222<br/>2222<br/>333333<br/>4444444<br/>555555<br/>6666";
        String str = "[50～51]<br/>A．补骨脂<br/>B．葶苈子<br/>C．吴茱萸<br/>D．牵牛子<br/>E．沙苑子<br/>1111";
        String b = "<br>";
        String c = "<br/>";
        if(str !=null && str!=""){
            String result = getResult(str,c);
//            String result1 = getResultBySplit(str,c);
            System.out.println(result);
        }
    }

    public static String getResult(String str,String re){
        if(str.indexOf(re) > -1){
            int index = str.indexOf(re);
            String result = str.substring(0,index);
            String remind = str.substring(index + re.length());
            String result2 = "<p>" + result + "<p/>";
            return result2 + getResult(remind,re);
        }
        return str;
    }


    public static String getResultBySplit(String str,String re){
        if(str.indexOf(re) > -1){
            StringBuilder builder = new StringBuilder();
            String[] items = str.split(re);
            for(String s : items){
                builder.append("<p>").append(s).append("</p>");
            }
            return builder.toString();
        }
        return str;
    }
}
